<template>
  <div class="movie-container">
    <div class="header">
      <div class="header-inner clearfix">
        <div class="movie-info-left">
          <div class="avatar-shadow">
            <img class="avatar" :src="movieInfo.moviePoster">
          </div>
        </div>
        <div class="movie-info-right">
          <div class="movie-info-msg">
            <h1 class="movie-name">{{ movieInfo.movieName }}</h1>
            <h1>&nbsp;|</h1>
            <ul>
              <li>{{ movieInfo.movieCategoryList }}</li>
              <li>{{ movieInfo.movieArea }} / {{ movieInfo.movieLength }}分钟</li>
              <li>{{ movieInfo.releaseDate }} {{ movieInfo.movieArea }} 上映</li>
            </ul>
          </div>
          <div class="movie-info-btn">
            <!--            <el-button class="buy-btn" type="primary" @click="toChooseSession">特惠购票</el-button>-->
          </div>
          <div class="movie-info-score">
            <div class="movie-index box-office-container">
              <span class="movie-index-title">累计票房</span>
              <div style="display: flex;align-items: flex-end;">
                <span class="box-office">{{ movieInfo.movieBoxOffice }}</span>
                <span class="unit">元</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="movie-info-detail-container">
      <div class="movie-info-detail clearfix">
        <div class="main-content">
            <!-- 根据时间筛选 -->
            <div class="movie-list">
              日期：
              <div v-for="(item, index) in week" :key="index" :style="{marginRight: '40px'}" >
                <span v-if="index === 0">今天</span>
                <span v-else-if="index === 1">明天</span>
                <span v-else-if="index === 2">后天</span>
                {{ item }}
              </div>
            </div>
            <!-- 根据影院筛选 -->
          <div class="movie-list">
            影院品牌：
            <div v-for="(item, index) in cinemas" :key="index" :style="{marginRight: '40px'}" >
              {{ item.label }}
            </div>
          </div>
            <!-- 根据影厅筛选 -->
          <div class="movie-list">
          影厅类型：
          <div v-for="(item, index) in halls" :key="index" :style="{marginRight: '60px'}" >
            {{ item.label }}
          </div>
        </div>

          <div class="mod-title">
            <h2>影院列表</h2>
          </div>


        </div>
      </div>
    </div>
  </div>
</template>

<script>
import movieItem from './../../components/movie/movie-item';
import moment from 'moment'

export default {
  name: "ChooseSession",
  components: {
    movieItem
  },
  data() {
    return {
      // 封装查询对象
      search:{

      },
      // 时间数组
      week: [],
      movieInfo: {
        moviePictures: []
      },
      movieId: this.$route.params.movieId,
      activeName: 'introduction',
      colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
      httpURL: this.global.base,
      total: 0,
      pageSize: 30,
      pageNum: 1,
      date: '',
      cinema: '',
      hall: '',
      movieList: [],
      timeList: [],
      sorry: false,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7 || time.getTime() > Date.now() + 4.32e8;
        }
      },
      cinemas: [
        {value: '1', label: '万达影城'},
        {value: '2', label: '星美国际影城'},
        {value: '3', label: '中影国际影城'},
        {value: '4', label: '博纳国际影城'},
        {value: '5', label: '横店电影城'}
      ],
      halls: [
        {value: '1', label: '普通厅'},
        {value: '2', label: 'IMAX厅'},
        {value: '3', label: '4DX厅'},
        {value: '4', label: '巨幕厅'},
        {value: '5', label: 'VIP厅'},
        {value: '6', label: '激光厅'},
        {value: '7', label: '杜比全景声厅'},
        {value: '8', label: '巨幕厅'},
      ]
    }
  },
  created() {
    this.getMovieInfo()
    // this.movieId = this.$route.params.movieId;
    this.movieId = this.$route.params.movieId
    //显示时间搜索框
    this.showTime();
    this.showCenimas();
  },
  methods: {
    showTime() {
      // 创建一个Date对象，表示当前的日期和时间
      const today = new Date();
// 创建一个数组，存储一周的星期名
      const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
// 创建一个空数组，用来存储今天和未来一周的日期和星期
      const week = [];
      // 使用一个循环，从今天开始，每次增加一天，直到生成七个元素
      for (let i = 0; i < 5; i++) {
        // 复制当前的日期对象，避免修改原对象
        let date = new Date(today);
        // 使用setDate方法，设置日期为今天加上循环的次数
        date.setDate(today.getDate() + i);
        // 使用getFullYear, getMonth, getDate方法，获取年月日的数值
        let year = date.getFullYear();
        let month = date.getMonth() + 1; // 注意月份是从0开始的，所以要加1
        let day = date.getDate();
        // 使用getDay方法，获取星期的索引，然后从数组中取出对应的星期名
        let weekday = weekdays[date.getDay()];
        // 使用模板字符串，拼接成一个格式化的日期和星期，例如"2023-11-21 星期二"
        let formatted = `${month}月${day}日`;
        // 将格式化的日期和星期，添加到数组中
        week.push(formatted);
        // 打印数组，查看结果
        this.week = week;
        console.log(week);
      }
    },
    showCenimas(){

    },
    async getMovieInfo() {
      const _this = this
      console.log('sysMovie/find/' + this.movieId)
      const {data: res} = await axios.get('sysMovie/find/' + this.movieId)
      if (res.code !== 200) return this.$message.error('数据查询失败')
      this.movieInfo = res.data
      this.movieInfo.moviePoster = this.httpURL + JSON.parse(res.data.moviePoster)[0]
      this.movieInfo.moviePictures = JSON.parse(this.movieInfo.moviePictures).map((obj, index) => {
        return this.httpURL + obj
      })
      this.movieInfo.movieCategoryList = this.movieInfo.movieCategoryList.map((obj, index) => {
        return obj.movieCategoryName;
      }).join(" ")
    },
    showPictures() {
      this.activeName = 'pictures'
    },
    //转到购票页面
    // toChooseSession(){
    //   let cinemaId = 1
    //   this.$router.push('/chooseSession/' + cinemaId)
    // }
  }
}
</script>

<style scoped>
.movie-list{
  display: flex;
  flex-wrap: wrap;
}
.pageHelper{
  display: flex;
  justify-content: center;
  margin: 40px 0px;
}

.no-cinema{
  display: flex;
  justify-content: center;
  margin-top: 40px;
  margin-bottom: 40px;
  font-size: 16px;
  color: #333;
}
.movie-container {

}

a {
  text-decoration: none;
  cursor: pointer;
}

.header {
  padding: 0;
  width: 100%;
  min-width: 1200px;
  background: url('../../assets/movie-info-background.jpg')
}

.header-inner {
  width: 1200px;
  margin: 0 auto;
  position: relative;
}

.clearfix::before, .clearfix::after {
  content: " ";
  display: table;
}

.clearfix::after {
  clear: both;
}

.movie-info-left {
  width: 300px;
  height: 370px;
  float: left;
  position: relative;
  top: 70px;
  overflow: hidden;
  z-index: 9;
}

.avatar-shadow {
  position: relative;
  margin: 0 30px;
  width: 240px;
  height: 330px;
  padding-bottom: 40px;
  background: url() no-repeat bottom;
}

.avatar {
  border: 4px solid #fff;
  height: 322px;
  width: 232px;
}

.movie-info-msg {
  position: absolute;
  color: #fff;
  font-size: 14px;
  z-index: 1;
}

.movie-name {
  width: 900px;
  margin-top: 0;
  font-size: 26px;
  line-height: 32px;
  font-weight: 700;
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-height: 64px;
}

.movie-ename {
  width: 340px;
  font-size: 18px;
  line-height: 1.3;
  margin-bottom: 14px;
}

ul {
  width: 250px;
  list-style: none;
  padding-left: 0;
  margin-bottom: 20px;
}

ul li {
  margin: 12px 0;
  line-height: 100%;
}

.movie-info-btn {
  position: absolute;
  bottom: 20px;
}

.buy-btn {
  margin-top: 10px;
  width: 250px;
  height: 40px;
  font-size: 16px;
  text-align: center;
}

.movie-info-score {
  position: absolute;
  top: 145px;
  left: 342px;
}

.movie-index {
  margin-bottom: 16px;
  color: #fff;
}

.box-office-container {
  display: flex;
  flex-direction: column;
}

.movie-index-title {
  font-size: 12px;
  margin-bottom: 8px;
}

.movie-score-num {
  font-size: 30px;
  color: #ffc600;
  height: 30px;
  line-height: 30px;
  margin-right: 10px;
}

.score-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
}

.box-office {
  font-size: 30px;
}

.unit {
  font-size: 12px;
  padding-left: 1px;
  line-height: 24px;
}

.movie-info-right {
  height: 300px;
  position: relative;
  margin-right: 30px;
  margin-left: 300px;
  margin-top: 70px;
}

.movie-info-detail-container {
  width: 1200px;
  margin: 0 auto;
}

.movie-info-detail {
  margin-top: 80px;
}

.main-content {
  width: 730px;
  float: left;
  margin-bottom: 20px;
}

.crumbs-nav-container {
  margin-bottom: 25px;
  color: #333;
}

.crumbs-nav-container a {
  color: inherit;
}

.el-tabs >>> .el-tabs__item {
  font-size: 20px;
}

.tab-body {
  margin-top: 40px;
}

.module {
  position: relative;
  margin-bottom: 60px;
}

.mod-title h2 {
  display: inline-block;
  margin: 0;
  padding: 0;
  font-weight: 400;
  font-size: 18px;
  color: #333;
  line-height: 18px;
}

.mod-title h2:before {
  float: left;
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  margin-right: 6px;
  background-color: #409EFF;
}

.mod-content {
  margin-top: 20px;
  color: #333;
}

.mod-content .dra {
  font-size: 14px;
  line-height: 26px;
}

.more {
  float: right;
  cursor: pointer;
  font-size: 14px;
  color: #999;
  padding-right: 14px;
  background: url() no-repeat 100%;
}

.portrait {
  margin-bottom: 6px;
  width: 128px;
  height: 170px;
  overflow: hidden;
}

.portrait .default-img {
  width: 128px;
  height: 170px;
}

.pictures-list {
  display: flex;
}

.pictures-list > .el-image:first-child {
  width: 465px;
  height: 258px;
}

.pictures-list .default-img {
  border-style: none;
  cursor: pointer;
  width: 126px;
  height: 126px;
}

.little-pictures {
  width: 262px;
  height: 262px;
  display: flex;
  flex-wrap: wrap;
  margin-left: 10px;
  justify-content: space-between;
}

#pane-pictures .little-pictures {
  width: 100%;
  justify-content: flex-start;
  margin-left: 0;
}

#pane-pictures .default-img {
  margin-top: 10px;
  margin-left: 10px;
}

.user-avatar {
  width: 50px;
  height: 50px;
  margin-right: 20px;
}


.main-header {
  font-size: 16px;
}

.user-name {
  margin-top: 2px;
}

.mod-title h2 {
  display: inline-block;
  margin: 0;
  padding: 0;
  font-weight: 400;
  font-size: 18px;
  color: #333;
  line-height: 18px;
}

.mod-title h2:before {
  float: left;
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  margin-right: 6px;
  background-color: #409EFF;
}
</style>
